export function pySegSort(arr,empty) {
  let hot = {
    data: arr.slice(0,10),
    index: '热门'
  }
  
  if( !String.prototype.localeCompare ) return null
  let letters = "*abcdefghjklmnopqrstwxyz".split(''),
      zh = "阿八嚓哒妸发旮哈讥咔垃痳拏噢妑七呥扨它穵夕丫帀".split(''),
      segs = [],
      curr
  letters.forEach( (letter,index) => {
    let _letter = letter.toUpperCase()

    let reg = new RegExp(`^[${_letter}${letter}]`)

    curr = {index: _letter, data:[]}
    arr.forEach((item) => {
      let singerName = item.singer_name
      if((!zh[index-1] || zh[index-1].localeCompare(singerName,"zh") <= 0) && ( singerName.localeCompare(zh[index],"zh") == -1) || ( reg.test(singerName) && /[A-Za-z]/.test(singerName)) ) {
        if( /[A-z]/.test(singerName) && !reg.test(singerName) ) return
        curr.data.push(item)
      }
    });
    if(empty || curr.data.length) {
      curr.data.sort(function(a,b){
        return a.singer_name.localeCompare(b.singer_name,"zh");
      })
      
      segs.push(curr)
    }
  });
  segs.unshift(hot)
  return segs;
}
